package io.renren.modules.mem_token.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.mem_token.entity.V9MemTokenEntity;
import io.renren.modules.mem_token.service.V9MemTokenService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-10-05 22:39:46
 */
@RestController
@RequestMapping("mem_token/v9memtoken")
public class V9MemTokenController {
    @Autowired
    private V9MemTokenService v9MemTokenService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("mem_token:v9memtoken:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9MemTokenService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{memId}")
    @RequiresPermissions("mem_token:v9memtoken:info")
    public R info(@PathVariable("memId") Long memId){
		V9MemTokenEntity v9MemToken = v9MemTokenService.getById(memId);

        return R.ok().put("v9MemToken", v9MemToken);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("mem_token:v9memtoken:save")
    public R save(@RequestBody V9MemTokenEntity v9MemToken){
		v9MemTokenService.save(v9MemToken);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("mem_token:v9memtoken:update")
    public R update(@RequestBody V9MemTokenEntity v9MemToken){
		v9MemTokenService.updateById(v9MemToken);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("mem_token:v9memtoken:delete")
    public R delete(@RequestBody Long[] memIds){
		v9MemTokenService.removeByIds(Arrays.asList(memIds));

        return R.ok();
    }

}
